//
//  yinDaoYeViewController.m
//  yiyou
//
//  Created by tangtangchitangtang on 2017/9/25.
//  Copyright © 2017年 tangtangchitangtang. All rights reserved.
//

#import "yinDaoYeViewController.h"

#import "LogingViewController.h"
#import "myViewController.h"
#import "workbenchViewController.h"
#import "homeViewController.h"
#import "Home2ViewController.h"
#import "Workbench2ViewController.h"
#import "My2ViewController.h"
#import "WXApi.h"
#import <UserNotifications/UserNotifications.h>
#import <AdSupport/AdSupport.h>
#import "newsViewController.h"
#import "WrittenDocumentsViewController.h"
#import "ReleaseCaseViewController.h"
#import "LegalAdviceViewController.h"



@interface yinDaoYeViewController ()<UIScrollViewDelegate>

@property (nonatomic,strong) UIScrollView *scrollView2;

@end

@implementation yinDaoYeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self wr_setNavBarBackgroundAlpha:0];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
 
    [self Qidong];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
    
}

-(void)Qidong{
    
    _scrollView2=[UIScrollView new];
    [self.view addSubview:_scrollView2];
    [_scrollView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.bottom.left.right.mas_equalTo(0);
    }];
    //必须设置
    _scrollView2.contentSize=CGSizeMake(_mainW*3,0);
    _scrollView2.showsHorizontalScrollIndicator=NO;
    _scrollView2.contentOffset=CGPointMake(0,0);
    _scrollView2.pagingEnabled=YES;
    _scrollView2.delegate=self;
    
    
    for(int i=0;i<3;i++){
        UIImageView *imgView=[UIImageView new];
        [_scrollView2 addSubview:imgView];
        [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.width.mas_equalTo(_mainW);
            make.height.mas_equalTo(_mainH);
            make.left.mas_equalTo(i*_mainW);
        }];
        NSString *imgUrl=[NSString stringWithFormat:@"启动页-%d",i+1];
        imgView.image=[UIImage imageNamed:imgUrl];
        if (i==2) {
            imgView.userInteractionEnabled=YES;
            UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jingRu)];
            [imgView addGestureRecognizer:tapGesture];
            
        }
    }
    
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    CGPoint points=scrollView.contentOffset;
    
    int page=points.x/_mainW;
    if (page==3) {
        [self jingRu];
    }
    
    
    
}

-(void)jingRu{
    
    
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    NSNumber *waiter_role=[userDic objectForKey:@"waiter_role"];
    
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    
    NSString *getAPPBanben=[ZQTools getAPPBanben];
    [user setObject:getAPPBanben forKey:@"getAPPBanben"];
    if (waiter_role.intValue==0) {
        homeViewController *shouye=[[homeViewController alloc] init];
        
        workbenchViewController *huDong=[[workbenchViewController alloc] init];
        
        myViewController *youJi=[[myViewController alloc] init];
        
        UINavigationController *nav1= [[UINavigationController alloc] initWithRootViewController:shouye];
        UINavigationController *nav2= [[UINavigationController alloc] initWithRootViewController:huDong];
        UINavigationController *nav3= [[UINavigationController alloc] initWithRootViewController:youJi];
        
        nav1.title=@"首页";
        nav2.title=@"工作台";
        nav3.title=@"我的";
        
        [nav1.tabBarItem setSelectedImage:[UIImage imageNamed:@"首页1"]];
        [nav1.tabBarItem setImage:[UIImage imageNamed:@"首页"]];
        
        [nav2.tabBarItem setSelectedImage:[UIImage imageNamed:@"工作台1"]];
        [nav2.tabBarItem setImage:[UIImage imageNamed:@"工作台"]];
        
        [nav3.tabBarItem setSelectedImage:[UIImage imageNamed:@"我的1"]];
        [nav3.tabBarItem setImage:[UIImage imageNamed:@"我的"]];
        
        [[UITabBar appearance] setTintColor:_backgroundColor];
        
        UITabBarController *bar=[[UITabBarController alloc] init];
        bar.viewControllers=@[nav1,nav2,nav3];
        
        self.view.window.rootViewController=bar;
        [self.view.window makeKeyAndVisible];
    }
    else{
        Home2ViewController *shouye=[[Home2ViewController alloc] init];
        Workbench2ViewController *huDong=[[Workbench2ViewController alloc] init];
        
        My2ViewController *youJi=[[My2ViewController alloc] init];
        
        UINavigationController *nav1= [[UINavigationController alloc] initWithRootViewController:shouye];
        UINavigationController *nav2= [[UINavigationController alloc] initWithRootViewController:huDong];
        UINavigationController *nav3= [[UINavigationController alloc] initWithRootViewController:youJi];
        
        nav1.title=@"首页";
        nav2.title=@"工作台";
        nav3.title=@"我的";
        
        [nav1.tabBarItem setSelectedImage:[UIImage imageNamed:@"首页1"]];
        [nav1.tabBarItem setImage:[UIImage imageNamed:@"首页"]];
        
        [nav2.tabBarItem setSelectedImage:[UIImage imageNamed:@"工作台1"]];
        [nav2.tabBarItem setImage:[UIImage imageNamed:@"工作台"]];
        
        [nav3.tabBarItem setSelectedImage:[UIImage imageNamed:@"我的1"]];
        [nav3.tabBarItem setImage:[UIImage imageNamed:@"我的"]];
        
        [[UITabBar appearance] setTintColor:_backgroundColor];
        
        UITabBarController *bar=[[UITabBarController alloc] init];
        bar.viewControllers=@[nav1,nav2,nav3];
        
        self.view.window.rootViewController=bar;
        [self.view.window makeKeyAndVisible];
    }
    
    
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
